home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / p_tapr / tnchst / host.c < prev    next >
Text File  |  1989-07-30  |  2KB  |  117 lines

  1. /*******
  2.  
  3. Host link controller.  Manages "host" links on the RS-232 port
  4. vis-a-vis c2 links of LOh.
  5.  
  6.  
  7. *********/
  8.  
  9.  
  10.     /* host literals */
  11. #include "host.lit"
  12.  
  13.     /* data structures, c2 structures */
  14. #include "\cpm\loh\c2istr.inc"
  15.  
  16.     /* host specific structures */
  17. #include "hoststrc.inc"
  18.  
  19.     /* data structure */
  20. #include "datastrc.inc"
  21.  
  22.  
  23. /********* variables common to all host links *************/
  24.  
  25.  
  26. struct    host_struct    hosts[1]    ;    /* set up for 1 hcb now */
  27.  
  28.  
  29.  
  30.  
  31.  
  32. /** reset the data counters, NULL the data link list pointers, for a
  33.     specific host **/
  34. hdreset( hcb )
  35. struct host_struct *hcb;
  36. {
  37.  
  38.     hcb->htxseq = hcb->hrxseq = hcb->hremseq = 0 ;
  39.                                 /* reset seq #s */
  40.  
  41.     hcb->htx = hcb->hrx = (struct data_struct *) NULL ;
  42.                 /* init link list pointers */
  43.  
  44. }
  45.  
  46. free_list( ptr )
  47. struct data_struct **ptr;
  48. {
  49.     struct    data_struct    *tmp;
  50.  
  51.     tmp = *ptr ;        /* traverse the list */
  52.  
  53.     while ( *ptr )        /* while there are rmng nodes */
  54.     {
  55.         tmp = (*ptr)->data_link ;    /* get ptr to next */
  56. #if MSDOS
  57.         free( *ptr );
  58. #else
  59.                 sw_free( DATABUFFER , *ptr );
  60. #endif
  61.                 /* free the buffer */
  62.         *ptr = tmp ;
  63.                 /* reload the list entry pointer */
  64.     } /* endwhile */
  65. }
  66.  
  67. /** clears the link list, frees remaining structures to DATABUFFER pool **/
  68. hdclear( hcb )
  69. struct host_struct *hcb;
  70. {
  71.     free_list( &hcb->htx );        /* free everything in the */
  72.     free_list( &hcb->hrx );        /* tx and rx data lists */
  73. }
  74.  
  75. /** free the elements in the linked list pointed to by the byte ptr
  76.     at the adress ptd to by the parameter  **/
  77.  
  78.  
  79.  
  80.  
  81. host_init()
  82. {
  83.     hosts[0].hstate    =    HSIDLE    ;    /* idle the host link */
  84. }
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. /** timer handler for hosts.  should be slept from an executive or
  92.     called periodically from something else, for each
  93.     host structure
  94.  **/
  95. hosttask( hcb )
  96. struct    host_struct    *hcb;
  97. {
  98.     if ( hcb->hstate != HSIDLE )        /* if not idling */
  99.     {
  100.         if ( hcb->htime )        /* if timer running */
  101.         {
  102.             if ( ! --hcb->htime )    /* if timer now expired */
  103.                 host_event( hcb , HTIMER_EVENT , NULL );
  104.                         /*   then show expired event*/
  105.         }
  106.     }
  107.  
  108. #if MSDOS
  109. #else
  110.     sleep( hosttask , hcb , BAK0 , HRETRYTIME );
  111. #endif
  112. }
  113.  
  114.  
  115.  
  116. main(){ }
  117.